<?php
/**
 * @author Inhere
 * @version v1.0
 * Use : Router管理服务
 * Date : 2015-1-10
 * RouterServiceProvider.php
 */
namespace ulue\cli\router;

use ulue\core\ioc\Container;
use ulue\core\ioc\InterfaceServiceProvider;

class RouterServiceProvider implements InterfaceServiceProvider
{
    /**
     * 注册一个服务提供者， RouterServiceProvider
     * @param  Container $container 传入容器
     * @throws \DInvalidArgumentException
     * @return mixed|void
     */
    public function register(Container $container)
    {
        $closure    = function($routePath)
        {
            $routePath = is_string($routePath) ? $routePath : null;

            return ( new Router($routePath) )->execute();
        };

        $container->share('router',$closure)->alias('app.router')->alias('application.router');
    }
}